import AesUtil from './AesUtil.js'
/**
 * token管理器
 * author：szxgood@yeah.net
 * date：2020-04-18
 */
class Token {
    setUUID(uuid) {  //phone
        sessionStorage.setItem('userId', uuid);
    }
    getUUID() {
        return sessionStorage.getItem('userId');
    }
    setToken(token) {
        sessionStorage.setItem('token', token);
    }
    setAccessToken(accessToken) {  //accesstoken
        sessionStorage.setItem('accessToken', accessToken);
    }
    setRefreshToken(refreshToken) { //refreshtoken
        sessionStorage.setItem('refreshToken', refreshToken);
    }
    setExpire(expire) {
        var expireTime = (new Date()).getTime() + expire;
        sessionStorage.setItem('expire', expireTime + "");
    }
    getExpire() {
        return sessionStorage.getItem('expire'); // error
    }
    getToken() {
        var token = sessionStorage.getItem('token');
        if (!token) {
            token = AesUtil.encrypt("rinigeguisun" + (new Date()).getTime());
            this.setToken(token);
        }
        return token;
    }
    getAccessToken() {
        return sessionStorage.getItem('accessToken');
    }
    getRefreshToken() {
        return sessionStorage.getItem('refreshToken');
    }
}
var token = new Token();
export default token;